<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>执行维修</title>
    <link rel="stylesheet" href="/lib/layui/layui/css/layui.css?20190817.1">
    <link rel="stylesheet" href="/lib/layui/layui/css/common.css">
    <script src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/global.js"></script>
    <script type="text/javascript" src="../../js/jquery/jquery-1.9.1.js"></script>
    <script src="../../js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/layui/layui/js/baseCode/base.js?v=2019072018:09" type="text/javascript" charset="utf-8"></script>
    <script src="/js/jquery/jquery.cookie.js"></script>
    <script src="/lib/layui/layui/js/common.js?v=20190723" type="text/javascript" charset="utf-8"></script>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .layui-card-header{
            border-bottom: 1px solid #eee;
        }
        .newTable{
            width: 80%;
            margin: 0 auto;
        }
        .layui-form .one{
            width: 100%;
            display: flex;
            flex-flow: row wrap;
            justify-content: space-around;
        }
        .layui-form-item{
            width: 48%;
        }
        .layui-inline{
            width: 40%;
            height: 38px;
        }
        .layui-form-label{
            width:64px;
        }
        select{
            width: 100%;
            height: 38px;
        }
        input::-webkit-input-placeholder {
            color: #aab2bd;
        }
        .buttonbottom{
            text-align: center;
        }
        .buttonbottom button{
            background-color: #009284;
            width: 90px;
            margin-top: 30px;
        }
        .layui-treeSelect .ztree li span.button.root_open:before, .layui-treeSelect .ztree li span.button.root_close:before{
            content: "\e623";
        }
        .layui-form-selectup dl {
            top: 42px;
            bottom: unset;
        }
        #borrowerUser{
            line-height: 38px;
        }
        .select .layui-input{
            height: 28px;
        }
        /*---------------*/

        #memo{
            width:696px;
        }
        .inp{
            height: 33px;
            border:none
        }
        .taby{
            width:100%;
            min-height: 25px;
            line-height: 25px;
            text-align: center;
            border:1px solid #e6e6e6;
            border-collapse: collapse;
        }
        td{
            border:1px solid #e6e6e6;
            height: 40px;
            line-height: 40px;
        }
        th{
            border:1px solid #e6e6e6;
        }
        #experiencebase .layui-table{
            width: 100%!important;
        }
        .btnbox{
            position: relative;
            width: 100%;
            height: 40px;
            line-height: 40px;
        }
        .seeFild{
            padding:5px 10px 0 0;
        }

        .equipmentInfo input{
            width: 97%;
        }
        .equipmentInfo label{
            width:85px;
        }
        .faultStyles{
            width:70%;
            float:left;
        }
        .fault_information{
            margin-top:10px;
        }
        .fault_information .layui-form-item{
            width:25%;
        }
        .fault_information .layui-form-item .layui-input-block{
            margin-left: 87px;
            position:relative;
        }
        .fault_information .layui-form-item .layui-input-block span{
            float: left;
            padding:10px 0 0 5px;
        }
        .technicalParm{
            margin-left: 1%;
            width: 100%;
        }
        @media screen and (max-width:1024px) {
            .fault_information .layui-form-item{
                width:35%;
            }
            .technicalParm{
                width:83%;
            }
        }
    </style>
</head>
<body>
<div class="mbox">
    <div class="layui-card">
        <div class="layui-card-body">
            <form class="layui-form" lay-filter="formTest" action=""style="width: 100%;
            margin: 0 auto;">
                <input type="text" name="equipId" style="display: none" id="layui-form">
                <div style="width: 100%;height:36px;line-height:36px;font-weight:bold;padding-left: 6px;background-color: #eeeeee">设备信息</div>
                <div class="one equipmentInfo" style="padding-top: 20px;">
                    <div class="layui-form-item">
                        <label class="layui-form-label" style=""><span style="color: red;">*</span>报修部门</label>
                        <div class="layui-input-block" id="deptoper">
                            <input type="text" name="borrowerdeptName" disabled placeholder="请输入" autocomplete="off" class="layui-input borrowerdeptName">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">报修人</label>
                        <div class="layui-input-block">
                            <input type="text" name="applicant" disabled placeholder="请输入" autocomplete="off" class="layui-input borrowerUser">
                        </div>
                    </div>
                </div>
                <div class="one equipmentInfo">
                    <div class="layui-form-item">
                        <label class="layui-form-label">设备名称</label>
                        <div class="layui-input-block" >
                            <input type="text" name="equipName" disabled  placeholder="请输入" autocomplete="off" class="layui-input typename">
                            <input type="hidden" name="equipId" disabled  placeholder="请输入" autocomplete="off" class="layui-input equipId">
                            <input type="hidden" name="equipStatuasId" disabled  placeholder="请输入" autocomplete="off" class="layui-input equipStatuasId">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width:85px;">固定资产编号</label>
                        <div class="layui-input-block">
                            <input type="text" name="equipNo" disabled placeholder="请输入" autocomplete="off" class="layui-input zichno">
                        </div>
                    </div>
                </div>
                <div class="one equipmentInfo">
                    <div class="layui-form-item">
                        <label class="layui-form-label">设备类型</label>
                        <div class="layui-input-block">
                            <input type="text" name="equipTypeName" disabled  placeholder="请输入" autocomplete="off" class="layui-input eqtype">
                            <input type="hidden" name="equipTypeId" disabled  placeholder="请输入" autocomplete="off" class="layui-input eqtypeId">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">出厂编号</label>
                        <div class="layui-input-block">
                            <input type="text" name="factoryNo" disabled placeholder="请输入" autocomplete="off" class="layui-input chnum">
                        </div>
                    </div>
                </div>
                <div class="one equipmentInfo">
                    <div class="layui-form-item">
                        <label class="layui-form-label">型号</label>
                        <div class="layui-input-block">
                            <input type="text" name="modelNo" disabled  placeholder="请输入" autocomplete="off" class="layui-input model">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">规格</label>
                        <div class="layui-input-block">
                            <input type="text" name="spec" disabled placeholder="请输入" autocomplete="off" class="layui-input spec">
                        </div>
                    </div>
                </div>
                <div id="eqba" style="width: 100%;height:36px;line-height:36px;font-weight:bold;padding-left: 6px;background-color: #eeeeee">故障信息</div>
                <div class="one fault_information">
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span style="color: red;">*</span>现象分类</label>
                        <div class="layui-input-block">
                            <div class="faultStyles">
                                <select disabled name="faultType" id="faultType" class="faultTypes" >
                                    <option value="">请选择</option>
                                </select>
                                <span style="float: left;padding:10px 0 0 22px"></span>
                            </div>
                            <span style="float: left;padding:10px 0 0 22px"></span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span style="color: red;">*</span>发生部位</label>
                        <div class="layui-input-block">
<%--
                            <input type="text" name="faultPosition" id="faultPosition" placeholder="请输入" autocomplete="off" class="layui-input faultPosition faultStyles">
--%>
                            <input type="text" disabled  name="faultPosition" id="faultPosition" placeholder="请输入" autocomplete="off" class="layui-input faultPosition faultStyles">

                        <%--<input type="text" name="faultPosition" disabled autocomplete="off" class="layui-input faultPosition"style="width:180px;float: left;">--%>
                            <span style="float: left;padding:10px 0 0 44px"></span>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label"><span style="color: red;">*</span>报修时间</label>
                        <div class="layui-input-block">
                            <input type="datetime" disabled name="applicationTime" id="yzdata"  autocomplete="off"  class="layui-input applicationTime faultStyles"placeholder="请选择时间">
                            <%--<input type="text" name="applicationTime" disabled id="yzdata"  autocomplete="off"  class="layui-input applicationTime"  style="width:180px;float: left;">--%>
                            <span style="float: left;padding:10px 0 0 10px"></span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"></label>
                        <div class="layui-input-block">
                        </div>
                    </div>
                </div>
                <div class="one">
                    <div class="layui-form-item technicalParm">
                        <label class="layui-form-label" style="margin-left: -11px;"><span style="color: red;">*</span>故障描述</label>
                        <div class="layui-input-block">
                            <textarea name="faultDesc" disabled id="technicalParm" placeholder="请输入内容" class="layui-textarea faultDesc" style="height: 10px;margin-left: -27px;"></textarea>
                            <%--<textarea name="faultDesc" disabled  id="technicalParm" placeholder="请输入内容" class="layui-textarea faultDesc" style="height: 10px;margin-left: -27px;"></textarea>--%>
                        </div>
                    </div>
                </div>
                <div >
                    <div class="inbox" style="margin-bottom:10px">
                        <%--<label class="layui-form-label">--%>
                            <%--附件名称--%>
                        <%--</label>--%>
                        <div id="attachmentName">

                        </div>
                    </div>
                </div>
                <div class="buttonbottom">
                    <button id="add-file-submit" class="layui-btn layui-btn-sm" lay-submit lay-filter="formDemo" style="display: none"></button>
                </div>
                <%--表格--%>
                <div class="btn" style="margin: 10px auto;">
                    <button type="button"  class="layui-btn layui-btn-sm jyk">经验库</button>
                    <button type="button"  class="layui-btn layui-btn-sm addjyk">添加到经验库</button>
                </div>
                <div>
                    <table class="taby">
                        <thead>
                        <tr style="  background-color: #f2f2f2;">
                            <th style="width: 200px; height:40px; line-height:40px;" lay-data="{field:'username', width:200}"></th>
                            <th lay-data="{field:'experience', width:400}">内部故障诊断&维修措施</th>
                            <th lay-data="{field:'sign'}">外部故障诊断&维修措施</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td>检测结果</td>
                            <td><input type="text" value="" name="inResult" class="layui-input inp inResult" autocomplete="off"></td>
                            <td><input type="text" value=""  name="outResult" class="layui-input inp outResult" autocomplete="off"></td>
                        </tr>
                        <tr>
                            <td>故障定位</td>
                            <td><input type="text" value=""  name="inFaultPosition" class="layui-input inp inFaultPosition" autocomplete="off"></td>
                            <td><input type="text" value=""  name="outFaultPosition" class="layui-input inp outFaultPosition" autocomplete="off"></td>

                        </tr>
                        <tr>
                            <td>原因分析</td>
                            <td><input type="text"value=""  name="inReason" class="layui-input inp inReason" autocomplete="off"></td>
                            <td><input type="text"value=""  name="outReason" class="layui-input inp outReason" autocomplete="off"></td>
                        </tr>
                        <tr>
                            <td>维修措施</td>
                            <td><input type="text" value="" name="inRepairMeasure" class="layui-input inp" id="inRepairMeasure"autocomplete="off"></td>
                            <td><input type="text" value="" name="outRepairMeasure" class="layui-input inp outRepairMeasure" autocomplete="off"></td>
                        </tr>
                        <tr>
                            <td>维修方式</td><%--下拉框--%>
                            <td>
                                <select name="inRepairMode"  id="inRepairMode" style="height: 28px">
                                    <option value="">请选择</option>
                                </select>
                            </td>
                            <td>
                                <select name="outRepairMode" class="outRepairMode" id="outRepairMode" style="height: 28px">
                                    <option value="">请选择</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>维修等级</td>
                            <td>
                                <select name="inRepairRank" class="inRepairRank" id="Deng" style="height: 28px" autocomplete="off">
                                    <option value="">请选择</option>
                                </select>
                            </td>
                            <td>
                                <select name="outRepairRank" class="outRepairRank" style="height: 28px" autocomplete="off">
                                    <option value="">请选择</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>维修预算</td>
                            <td><input type="text" value="" name="inPrice" class="layui-input inp inPrice" autocomplete="off"></td>
                            <td><input type="text" value="" name="outPrice" class="layui-input inp outPrice" autocomplete="off"></td>
                        </tr>
                        <tr>
                            <td>计划完成时间</td>
                            <td><input type="text" value=""   name="inPlanTime" class="layui-input inp inPlanTime none" autocomplete="off"></td>
                            <td><input type="text" value=""   name="outPlanTime" class="layui-input inp outPlanTime none" autocomplete="off"></td>
                        </tr>
                        <tr>
                            <td>诊断人员</td>
                            <td><input type="text" value=""   name="inPerson" class="layui-input inp inPerson none" autocomplete="off"></td>
                            <td><input type="text" value=""   name="outPerson" class="layui-input inp outPerson none" autocomplete="off"></td>
                        </tr>
                        </tbody>
                    </table>
                </div>

        </div>
    </div>
</div>
<div class="mbox" id="experiencebase" style="display: none">
    <div class="layui-card">
        <div class="layui-form-item" style="width:100%">
            <div class="layui-inline-block">
                <label class="layui-form-label">经验代码</label>
                <div class="layui-input-inline">
                    <input type="tel" name="experNo" lay-verify="required|phone" autocomplete="off" class="layui-input experNo">
                </div>
            </div>
            <div class="layui-inline-block">
                <label class="layui-form-label">设备类型</label>
                <div class="layui-input-inline" id="equipmentType">
                    <input type="text" id="tree" lay-filter="tree" class="layui-input" placeholder="请选择">
                    <input name="equipTypeId" id="equipTypeTreeId" type="hidden"  placeholder="请选择">
                </div>
            </div>
            <div class="layui-inline-block">
                <label class="layui-form-label">发生部位</label>
                <div class="layui-input-inline">
                    <input type="text"  lay-verify="email"  autocomplete="off" class="layui-input fault">
                </div>
                <button type="button" class="layui-btn jykbtn">搜索</button>
            </div>
        </div>
        </form>
        <table id="baseSettlement" lay-filter="baseSettlement" style="margin-top:50px;"></table>
    </div>
</div>
<script type="text/html" id="toolbar">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" type="button" lay-event="addd" style="width: 70px">选择设备</button>
        <button class="layui-btn layui-btn-sm" lay-event="pdel" style="width: 70px">删除</button>
    </div>
</script>
<script>
    var idkey=13;
    var datas="",
        borrow="";
    var SettlementTable;
    var userId=$.cookie('userId');
    var userName=$.cookie('userName');
    $("#borrowerOperationUser").val(userName);
    var deptId=0;
    var repalogId = parent.repalogId;
    var experienceId;//经验库Id
    function getQueryString(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    }
    var zxwxbtn = getQueryString("zxwxbtn");
    var table;
    layui.use(['form', 'layer','table', 'element','upload','laydate','treeSelect'], function() {
        var form = layui.form
            , layer = layui.layer
            ,element = layui.element
            ,table = layui.table
            ,upload = layui.table
            ,laydate = layui.laydate
            , treeSelect = layui.treeSelect;
        var $ = layui.jquery;
        $(".inPlanTime").val(nowformat)
        $(".outPlanTime").val(nowformat)
        laydate.render({
            elem: '.inPlanTime'
            , trigger: 'click'//呼出事件改成click
            , format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '.outPlanTime'
            , trigger: 'click'//呼出事件改成click
            , format: 'yyyy-MM-dd'
        });
        //下拉树加载
        treeSelect.render({
            // 选择器
            elem: '#tree',
            // 数据
            data: '/equipmentType/selectEquipTypeTree',
            // 异步加载方式：get/post，默认get
            type: 'get',
            // 占位符
            placeholder: '请选择',
            // 是否开启搜索功能：true/false，默认false
            search: true,
            // 一些可定制的样式
            style: {
                folder: {
                    enable: true
                },
                line: {
                    enable: true
                }
            },
            // 点击回调
            click: function(d){
                // console.log($('#'+d.current.tId).parent('ul').prev().attr('title'))
                $('input[name="equipTypeId"]').val(d.current.id);

                if($('#'+d.current.tId).parent('ul').prev().attr('title')=='传感器'){
                    $('#directionId option[value="SENSOR_DIRECTION3"]').prop('selected','selected');
                    //shouHide('SENSOR_DIRECTION3')
                }else{
                    $('#directionId option[value=""]').prop('selected','selected');
                    $(".hide").hide();
                }
                form.render()

            },
            // 加载完成后的回调函数
            success: function (d) {
                var treeId = $('#equipmentType .layui-treeSelect-body').attr('id')
                var treeObj = $.fn.zTree.getZTreeObj(treeId)
                var nodes = treeObj.transformToArray(treeObj.getNodes());
                for (var i=0, l=nodes.length; i < l; i++) {
                    if (nodes[i].isParent){
                        treeObj.setChkDisabled(nodes[i], true);
                    }
                }
            }
        });
        /*----------------------经验库里面的select下拉数据-------------------------*/
        //渲染经验库条件搜索的下拉框 faultType
        $.ajax({
            url: '/equipment/selectAllCommonCode?parentTyepNo=EQUIP_FAILURE'
            , type: 'post'
            , success: function (res) {
                var fault = ''
                for (var i = 0; i < res.data.length; i++) {
                    fault += '<option value="' + res.data[i].codeNo + '">' +  res.data[i].codeName + '</option>'
                }
                $('.faultType').append(fault)
                form.render('select');
            }
        })




        /*-----------------------------------------------*/

        /*
        * ***************经验库的表格*************
         */

        //经验库的表格
        var tableIns= table.render({
            elem: '#baseSettlement'
            ,url:'/experience/selectAllEquipmentExperience'
            ,toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板查
            ,defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                title: '提示'
                ,layEvent: 'LAYTABLE_TIPS'
                ,icon: 'layui-icon-tips'
            }]
            ,page: {
                layout: ['prev', 'page', 'next',  'skip','count','limit',]
                ,limits:[5,10,15,20,25,30,35,40,45,50]
            }//自定义分页布局
            ,title: '经验库表格'
            ,cols: [[
                {type: 'checkbox'}
                ,{field:'experNo', title:'经验代码'}
                ,{field:'equipName', title:'设备名称'}
                ,{field:'equipNo', title:'固定资产编号'}
                ,{field:'equipTypeName', title:'设备类型'}
                ,{field:'factoryNo', title:'出厂编号'}
                ,{field:'spec', title:'规格'}
                ,{field:'modelNo', title:'型号'}
                ,{field:'faultTypes', title:'现象分类'}
                ,{field:'faultPosition', title:'发生部位'}
                ,{field:'faultDesc', title:'故障描述'}
            ]]
            ,limit:5
            ,done:function(res){
            }
        });





        /*
        ***************执行维修的页面的ajax*************
        *
         */
        $.ajax({
            url: '/equipment/selectByReparlog?repalogId=' + repalogId,
            type: 'post',
            dataType: 'json',
            success: function (res) {
                $(".borrowerdeptName").val(res.data[0].deptName)
                $('.borrowerUser').val(res.data[0].userName)
                var inRepairMode = res.data[0].inRepairMode;
                var outRepairMode = res.data[0].outRepairMode;
                var inRepairRank = res.data[0].inRepairRank;
                var outRepairRank = res.data[0].outRepairRank;
                $.ajax({//渲染设备维修方式下拉框
                    url: '/equipment/selectAllCommonCode?parentTyepNo=EQUIP_REPAIR_MODE',
                    type: 'post',
                    dataType: 'json',
                    success: function (res) {

                        var $select = $("select[name='inRepairMode']");   //定义的维修方式内部的变量
                        var $selein = $("select[name ='outRepairMode']")   //定义的维修方式外部的变量
                        var selectFs = res.data
                        //方式
                        var InoptionFs = "";
                        var OutoptionFs = "";
                        for (var i = 0; i < selectFs.length; i++) {
                            if(inRepairMode == selectFs[i].codeName){
                                InoptionFs += '<option selected value="' + selectFs[i].codeNo + '">' + selectFs[i].codeName + '</option>'
                            }else{
                                InoptionFs += '<option value="' + selectFs[i].codeNo + '">' + selectFs[i].codeName + '</option>'
                            }
                            if(outRepairMode == selectFs[i].codeName){
                                OutoptionFs += '<option selected value="' + selectFs[i].codeNo + '">' + selectFs[i].codeName + '</option>'
                            }else{
                                OutoptionFs += '<option value="' + selectFs[i].codeNo + '">' + selectFs[i].codeName + '</option>'
                            }
                        }
                        $select.append(InoptionFs)
                        $selein.append(OutoptionFs)
                        form.render('select');
                    }
                })
                //渲染现象分类
                $.ajax({
                    url: '/equipment/selectAllCommonCode?parentTyepNo=EQUIP_FAILURE'
                    , type: 'post'
                    , success: function (res1) {
                        var fault = ''
                        for (var i = 0; i < res1.data.length; i++) {
                            if(res.data[0].faultType== res1.data[i].codeName){
                                fault += '<option selected value="' + res1.data[i].codeNo + '">' +  res1.data[i].codeName + '</option>'
                            }else{
                                fault += '<option value="' + res1.data[i].codeNo + '">' +  res1.data[i].codeName + '</option>'
                            }
                        }
                        $('#faultType').append(fault)
                        form.render('select');
                    }
                })
                $.ajax({//渲染设备维修等级下拉框
                    url: '/equipment/selectAllCommonCode?parentTyepNo=EQUIP_REPAIR_RANK',
                    type: 'post',
                    dataType: 'json',
                    success: function (res) {
                        var $select1 = $("select[name ='inRepairRank']");  //定义的维修等级外部的变量
                        var $seleout = $("select[name ='outRepairRank']")   //定义的是维修等级外部的变量
                        var selectDj = res.data;
                        var InoptionDj = "";
                        var OutoptionDj = "";
                        for (var i = 0; i < selectDj.length; i++) {
                            if(inRepairRank == selectDj[i].codeName){
                                InoptionDj += '<option selected value="' + selectDj[i].codeNo + '">' + selectDj[i].codeName + '</option>'
                            }else{
                                InoptionDj += '<option value="' + selectDj[i].codeNo + '">' + selectDj[i].codeName + '</option>'
                            }
                            if(outRepairRank == selectDj[i].codeName){
                                OutoptionDj += '<option selected value="' + selectDj[i].codeNo + '">' + selectDj[i].codeName + '</option>'
                            }else{
                                OutoptionDj += '<option value="' + selectDj[i].codeNo + '">' + selectDj[i].codeName + '</option>'
                            }
                        }
                        $select1.append(InoptionDj)
                        $seleout.append(OutoptionDj)
                        form.render('select');
                    }
                })
                //$("select[name='borrowerdeptName']").val(res.data.deptId)
                form.render('select');
                form.val("formTest", res.data[0]);   //赋值input框的值,用于数据回显
                $("#attachmentName").empty()
                var attach = ""
                for(var i=0;i<res.obj.limsEquipReparlogFiles.length;i++){
                    var attId = res.obj.limsEquipReparlogFiles[i].attachmentId;
                    var repairId = res.data[0].repalogId;
                    var attName = res.obj.limsEquipReparlogFiles[i].attachmentName;
                    if(attId!=''&&attName!=''&&attId!=undefined&&attName!=undefined){
                        var attachIdArr = attId.split(',');
                        var attachNameArr = attName.split(',');
                        for(var j=0;j<attachIdArr.length;j++){

                            var attachId = "\""+attachIdArr[j]+"\"";
                            var repairId = repairId;
                            var attachName = attachNameArr[j];
                            if(attachId!=''&&attachName!=''){

                                attach+="<div id='attachId"+repairId+"' style='margin-left:10px;padding: 10px 0 10px 0'><label class='seeFild'>附件名称</label><label style='margin-right: 10px'>"+attachName+"</label><button type='button' class='layui-btn layui-btn-sm' onclick='lookFile("+attachId+")'>查看</button><button type='button' class='layui-btn layui-btn-sm' onclick='downFile("+attachId+")'>下载</button></div>"
                            }
                        }
                    }

                }
                $("#attachmentName").append(attach)
            }
        })
        $("#yzdata").val(new Date().Format("yyyy-MM-dd"))
        form.on('select(borrowerdeptName)', function (data) {
            deptId = data.elem.value;
        });


        //经验库
        $('.jyk').click(function () {
            tableIns.reload({
                url:'/experience/selectAllEquipmentExperience',
                page:true
            })
            layer.open({
                type:1,
                title:'添加到经验库',
                area:['100%','100%'],
                maxmin:true,
                content:$('#experiencebase')
                ,btn: ['确定', '取消'],
                yes: function(index, layero){
                    layer.close(index); //如果设定了yes回调，需进行手工关闭
                    $.ajax({//根据经验库Id查询数据回显到页面上
                        url:'/experience/selectEquipmentByExperId?dataType=str',
                        type:'post',
                        dataType: 'json',
                        data:{experId:experienceId},
                        success:function (res) {
                            console.log(res.object,'experience')
                            //$('#inRepairMode option[value=""]').prop('selected','selected');
                            //渲染 inRepairMode
                            $("#inRepairMode").each(function() {
                                // this代表的是<option></option>，对option再进行遍历
                                $(this).children("option").each(function() {
                                    // 判断需要对那个选项进行回显
                                    if(this.value == res.object.inRepairMode) {
                                        // 进行回显
                                        $(this).attr("selected","selected");
                                    }
                                });
                            });

                            //渲染 outRepairMode
                            $("#outRepairMode").each(function() {
                                // this代表的是<option></option>，对option再进行遍历
                                $(this).children("option").each(function() {
                                    // 判断需要对那个选项进行回显
                                    if(this.value == res.object.outRepairMode) {
                                        // 进行回显
                                        $(this).attr("selected","selected");
                                    }
                                });
                            });

                            //渲染 inRepairRank
                            $("#inRepairRank").each(function() {
                                // this代表的是<option></option>，对option再进行遍历
                                $(this).children("option").each(function() {
                                    // 判断需要对那个选项进行回显
                                    if(this.value == res.object.inRepairRank) {
                                        // 进行回显
                                        $(this).attr("selected","selected");
                                    }
                                });
                            });

                            //渲染 outRepairRank
                            $("#outRepairRank").each(function() {
                                // this代表的是<option></option>，对option再进行遍历
                                $(this).children("option").each(function() {
                                    // 判断需要对那个选项进行回显
                                    if(this.value == res.object.outRepairRank) {
                                        // 进行回显
                                        $(this).attr("selected","selected");
                                    }
                                });
                            });
                            form.render('select');
                            form.val("formTest",res.object);   //赋值input框的值,用于数据回显
                        }

                    })
                }
            })
            table.on('checkbox(baseSettlement)', function(obj){
                console.log(obj.data.experId); //选中行的相关数据
                experienceId = obj.data.experId;
            });

        })
        /*
        *    -----------------经验库的搜索功能------------
         */
        $('.jykbtn').click(function(){
            var jydm = $(".experNo").val()
            var equipType=$("#equipTypeTreeId").val()
            var phenomenon = $('#faultType').val()
            var siteof =  $('.fault').val()
            if(jydm==''&&equipType==''&&phenomenon==''&&siteof==''){
                tableIns.reload({
                    url:'/experience/selectAllEquipmentExperience',
                    page:true
                })
            }else{
                tableIns.reload({
                    url:'/experience/getEquipBySearch',
                    where:{
                        experNo:jydm,
                        equipTypeId:equipType,
                        faultType:phenomenon,
                        faultPosition:siteof
                    },
                    page:true
                })
            }


        })

        //添加到经验库
        $('.addjyk').click(function(res){
            // layer.open({
            //     type: 2 //此处以iframe举例
            //     ,title: '添加经验'
            //     ,area: ['100%', '100%']
            //     ,maxmin: true
            //     ,content: '/experience/goToAddExperience?addbttn=getCheckData'
            //     ,btn: ['保存', '取消']
            //
            // });
            //alert();
            $.ajax({
                url:'/experience/addExperience',
                type:'post',
                dataType:'json',
                data:addDatas(),
                success:function(res){
                    layer.msg(res.msg)
                }
            })

        })






    })

    function Xrborrow(bo) {
        $("#show").remove();
        $("#borrowerUser").html("<span id='show'>" + bo.userName + "</span>");
        $("#borrowerUser").next().val(bo.userId);
        $("#borrowerUser").next().attr("da-id",bo.userId);

    }
    function xuanren(me) {
        if (me == 1) {
            borrow = "borrow";
            if (deptId == 0) {
                layui.layer.msg("请选择借用部门")
                return false;
            }
        }
        $.popWindow("../common/lmisSelectUserExp?0");
    }
    //解决下拉框内有数据undefined问题
    function a(value) {
        if (value == undefined) {
            return ""
        }
        return value
    }
    function deleteItem(item, list) {
        // 先遍历list里面的每一个元素，对比item与每个元素的id是否相等，再利用splice的方法删除
        for (var key in list) {
            if (list[key].equipId === item) {
                list.splice(key, 1)
            }
        }
    };

    //父级页面调用子级页面
    function addData() {
        var ownerLog = {};

        return ownerLog;
    }

    function addjData() {
        var jsondata = layui.table.checkStatus('Settlement').data;
        return jsondata;
    }
    //将毫秒数转为yyyy-MM-dd格式时间
    function format(t) {
        var str = "";
        var nnow = new Date(t);
        var year = nnow.getFullYear();
        var month = nnow.getMonth() + 1;
        var day = nnow.getDate();
        str = year + "-" + month + "-" + day;
        return str;
    }

    //监听设备类型下拉框
    $(function(){
        $("#equipmentType").click(function() {
            $(document).scrollTop(100)
            // $('.mbox').css('margin-bottom','40px')
        });
    })


    //获取当前时间  年月日
    function nowformat() {
        var  nstr = "";
        var now = new Date();
        var nyear = now.getFullYear();
        var nmonth = now.getMonth()+1;
        var nday = now.getDate();
        if(nmonth<10){
            nmonth = "0"+nmonth;
        }
        if(nday<10){
            nday = "0"+nday;
        }
        nstr = nyear+"-"+nmonth+"-"+nday;
        return nstr;
    }

    //父级页面调用子级页面
    function addDatas() {
        var experience = {};
        experience.equipId = $(".equipId").val()
        experience.equipName = $('.typename').val();
        experience.equipNo = $('.zichno').val();
        experience.equipTypeId = $('.eqtypeId').val();//
        experience.equipTypeName = $('.eqtype').val();
        experience.equipStatuasCode = $('.equipStatuasId').val();
        experience.factoryNo = $('.chnum').val();
        experience.modelNo = $('.model').val();
        experience.spec = $('.spec').val();
        experience.faultType = $('.faultTypes').val();
        experience.faultDesc = $(".faultDesc").val();
        experience.faultPosition = $('.faultPosition').val();
        experience.inResult = $('.inResult').val();
        experience.outResult = $('.outResult').val();
        experience.inFaultPosition = $('.inFaultPosition').val();
        experience.outFaultPosition = $('.outFaultPosition').val();
        experience.inReason = $('.inReason').val();
        experience.outReason =  $('.outReason').val();
        experience.inRepairMeasure =  $('#inRepairMeasure').val();
        experience.outRepairMeasure = $('.outRepairMeasure').val();
        experience.inRepairMode =  $("#inRepairMode").val();
        experience.outRepairMode = $('.outRepairMode').val();
        experience.inRepairRank = $("#Deng").val();
        experience.outRepairRank = $('.outRepairRank').val();
        experience.inPrice = $(".inPrice").val()
        experience.outPrice = $('.outPrice').val();
        //experience.equipId=equipmentId;
        experience.inPlanTime = $(".inPlanTime").val()
        experience.outPlanTime = $(".outPlanTime").val()
        experience.inPerson = $(".inPerson").val()
        experience.outPerson = $(".outPerson").val()


        return experience;
    }

    function lookFile(repalogId){//查看附件
        if (repalogId == undefined || repalogId == "") {
            layer.msg("文件已被损坏，无法查看");
        } else {
            selectFile(repalogId,'equipment');
            //window.location.href = "/equipment/limsDownload?model=" + model + "&attachId=" + attachId  下载
        }
    }
    function downFile(repalogId){//下载附件
        if (repalogId == undefined || repalogId == "") {
            layer.msg("文件已被损坏，无法下载");
        } else {
            //var equipmentRepair ="equipmentRepair"
            window.location.href = "/equipment/limsDownload?model=equipment&attachId=" +repalogId
        }
    }
</script>
</body>
</html>